<template>
  <div>
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>待审批采购
          </p>
        </div>
        <div class="topright">
          <!--<el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>-->
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>

    <div class="table">
      <el-table
        ref="multipleTable"
        :data="info"
        tooltip-effect="dark"
        style="width:100%"
        border
      >
        <el-table-column label="时间" align="center">
          <template slot-scope="scope">
            {{scope.row.createDate | dateFilter}}
          </template>
        </el-table-column>
        <el-table-column label="采购单号" align="center" prop="buyNo"></el-table-column>
        <!--<el-table-column label="采购金额" align="center" prop="buyMoney"></el-table-column>-->
        <el-table-column label="申请人" align="center" prop="buyUser"></el-table-column>
        <el-table-column label="申请总价" align="center" prop="buyMoney"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <!--<a class="options" @click="dialogVisible = true">查看详情</a>-->
            <a class="options" @click.prevent="$router.push({name:'seDetail',params:{flag:1,id:scope.row.buyId}})">查看详情</a>
            <a class="options" v-if="scope.row.flowStatus == 20" @click="configs(scope.row.buyId)">审核意见</a>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="component-paging" v-if="info.length > 0">
      <div class="table-bottom">
        <div class="bottom-left"></div>
        <div class="paging">
          <div class="paging-left">
            <p>
              共
              <span>{{Math.ceil(total/pageSize)}}</span> 页/
              <span>{{total}}</span> 条数据
            </p>
          </div>
          <el-pagination
            background
            @size-change="SizeChange($event,dataInit,currentPage,pageSize)"
            @current-change="CurrentChange($event,dataInit,currentPage,pageSize)"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30]"
            :page-size="pageSize"
            layout="sizes, prev, pager, next, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
    </div>

    <!-- 查看详情弹窗 -->

  <!--<div class="component-model">-->
      <!--<el-dialog :title="modelTitle" :visible.sync="dialogVisible" width="600px">-->
    <!--<el-table-->
        <!--ref="multipleTable"-->
        <!--:data="info"-->
        <!--tooltip-effect="dark"-->
        <!--style="width:100%"-->
        <!--border-->
      <!--&gt;-->
        <!--<el-table-column label="序号" align="center" width="100" prop="name"></el-table-column>-->
        <!--<el-table-column label="材料名称" align="center" width="100" prop="name"></el-table-column>-->
        <!--<el-table-column label="型号" align="center" width="100" prop="name"></el-table-column>-->
        <!--<el-table-column label="采购数量" align="center" width="100" prop="name"></el-table-column>-->
        <!--<el-table-column label="单价" align="center"  prop="name"></el-table-column>-->

      <!--</el-table>-->
        <!--<span slot="footer" class="dialog-footer">-->
          <!--<el-button @click="dialogVisible = false">取消</el-button>-->
          <!--<el-button @click="dialogVisible = false;addPersons">确定</el-button>-->
        <!--</span>-->
      <!--</el-dialog>-->
    <!--</div>-->

  <!-- 审核意见弹窗 -->


  <div class="component-model">
      <el-dialog :title="Title" :visible.sync="Visible" width="600px">

      <span>审核意见：</span>
      <el-radio v-model="radio" label="1">同意</el-radio>
      <el-radio v-model="radio" label="2">驳回</el-radio>
      <div style="margin-top:20px;">
        <span style="vertical-align:top;margin-left:40px;">备注：</span>
        <el-input type="textarea" v-model="desc" style="width:180px;resize:none;"></el-input>
      </div>

        <span slot="footer" class="dialog-footer">
          <el-button @click="Visible = false">取消</el-button>
          <el-button @click="addPerson">确定</el-button>
        </span>
      </el-dialog>
    </div>


  </div>
</template>
<script>
  export default {
    data() {
      return {
        Visible:false,
        dialogVisible: false,
        modelTitle:"查看详情",
        Title:"审核意见",
        ruleForm: { name: "",orgName:"",nickname:"",},

        radio: '1',
        desc:"",
        info: [],
        // 数据总条数
        total: 1,
        // 每页显示数据的条数
        pageSize: 10,
        // 当前显示的页面页码
        currentPage: 1,
        buyId:'',
      };
    },
    created(){

    },
    mounted(){
      this.dataInit();
    },
    methods: {
      dataInit(){
        let that = this;
        let suCb = function(res){
          that.info = res.data.data.list;
          that.total = res.data.data.rowCount;
          console.log(res.data)
        }
        let erCb = function(res){
          console.log(res)
        }
        let postData = {
          buySource:'1',
          pageCurrent:that.currentPage,
          pageSize:that.pageSize
        }
        let palyParam = {
          url: "/api/web/proBuyApply/getDepartmentCheckList",
//          url: "/api/web/proBuyApply/getCheckList",
          methods:'post',
          data: postData,
          success: suCb,
          error: erCb,
        }
        that.$https(palyParam)
      },
      //点击审核意见
      configs(val){
        this.Visible = true;
        this.buyId = val;
      },
      //点击确定审核意见弹框同意
      addPerson(){
          this.Visible = false;
//          radio  1 同意  2  驳回
          console.log(this.radio);
          console.log(this.desc);
          let selectRadio = "";
          if(this.radio == 1){
            selectRadio = '21'
          }else{
            selectRadio = '29'
          }
        let that = this;
        let suCb = function(res){
          console.log(res)
          that.dataInit();
        }
        let erCb = function(res){
          console.log(res)
        }
        let postData = {
          proBuyApply:{
            buyId:that.buyId,
            flowStatus:selectRadio,
            checkOpinion:that.desc
          }
        }
        let palyParam = {
          url: "/api/web/proBuyApply/updateBuyApplyState",
          methods:'post',
          data: postData,
          success: suCb,
          error: erCb,
        }
        that.$https(palyParam)
      }
    },
    watch: {}

  };
</script>
<style scoped>
  .table{
    width: 1100px;
    margin: 20px auto 0;
  }
  a{
    cursor: pointer;
    color: #1ABC9C;
    text-decoration: none;
  }

/* 弹窗样式 */

</style>
